<template>
  <view class="page container">
    <textarea
      class="input"
      v-model="contentRef"
      placeholder="请输入您宝贵的意见或建议"
      :placeholder-style="{ color: '#999', fontSize: '28rpx' }"
      maxlength="300"
      @input="onInput"
    />

    <button class="btn-confirm button" @tap.stop="onConfirm">提交</button>
  </view>
</template>

<script setup>
import { ref } from 'vue';
const contentRef = ref('');

const onInput = (e) => {
  contentRef.value = e.detail.value;
  console.log('输入0：', contentRef.value);
};

const onConfirm = () => {
  console.log('提交：', contentRef.value);
  if (!contentRef.value) {
    uni.showToast({
      title: '请输入您的意见或建议',
      icon: 'none'
    });
    return;
  }
  uni.showLoading();
  http
    .request({
      url: '/xx/feedback',
      method: 'post',
      data: {
        content: contentRef.value
      }
    })
    .then(() => {
      uni.hideLoading();
      uni.showToast({
        title: '提交成功',
        icon: 'none'
      });
      uni.navigateBack({
        delta: 1
      });
    });
};
</script>

<style lang="scss" scoped>
@import './feedback.scss';
</style>
